<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/sinopac-fn" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>待覆核作業清單</title>
	<link rel="stylesheet" href="${fn:url('/form/CSS/tabs.css')}">
	<script type="text/javascript" src="${fn:url('/js/jQuery/jquery-1.8.2.min.js')}"></script>
	<script type="text/javascript" src="${fn:url('/js/jQuery/jquery_DOMWindow.js')}"></script>
	<script type="text/javascript" src="${fn:url('/js/tools/formUtil.js')}"></script>
	<script>
		$(document).ready(function(){
			$('input[name=btnOK]').click(function(){
				//alert("核准"+$('.table-style tr').find("td:eq(6) :checkbox:checked").length);
				//alert("拒絕"+$('.table-style tr').find("td:eq(7) :checkbox:checked").length);
				//>input:checkbox").is(":checked") == true
				if($('.table-style tr').find("td:eq(6) :checkbox:checked").length>0
						|| $('.table-style tr').find("td:eq(7) :checkbox:checked").length>0){
					var f = $('#form1');
					f.prop('action','${fn:url('/SupervisorReconfirm/confirmAuthorize.action')}');
					f.submit();
				}else{
					alert('請至少勾選一個');
				}
			});
			$('input[name=btnCancel]').click(function(){
				var f = $('#form1');
				f.prop('action','${fn:url('/SupervisorReconfirm/index.action')}');
				f.submit();
			});
			$('input[name=confirm]').click(function(){
				$('input[name=confirm]').closeDOMWindow({windowSourceID: '.errorDiv'});
				if($('.table-style').size()==0){
					alert('無需要覆核的業務！');
					var f = $('#form1');
					f.prop('action','${fn:url('/SupervisorReconfirm/backMain.action')}');
					f.submit();
				}
			});
			$('.example5closeDOMWindow').closeDOMWindow({windowSourceID: '.errorDiv'});
			if($("#errorMsg").val() != ""){
				var errorMsg = $("#errorMsg").val()+"";
				$(".errorDiv").find("#error").text(errorMsg);
				$.openDOMWindow({ 
			    	windowSourceID: '.errorDiv',
			        height:340,  
			        width:500, 
			        overlay:1, 
			        overlayColor: '#A9A9A9',
			        windowPadding:20,
			        modal:1,
			        borderColor:'steelblue',
			        borderSize:'2', 
			        positionLeft:120, 
			        positionTop:-150,
			    });
			}else{
				if($('.table-style').size()==0){
					alert('無需要覆核的業務！');
					var f = $('#form1');
					f.prop('action','${fn:url('/SupervisorReconfirm/backMain.action')}');
					f.submit();
				}
			}
		});
		function getCustomer_id(custId){
			var form = $('#form1');
			form.prop('action','/sinopac/CustomerApply/index.action');
			console.info(custId);
			$('input[name=custId]').val(custId);
			form.submit();
		}
		function getCustomer_id(voValue){
			var form = $('#form1');
			form.prop('action', '${fn:url('/Index/chkCustId.action')}');
			form.append('<input type="hidden" name="function_num" value="2" />');
			form.append('<input type="hidden" name="custId" value="'+voValue+'" />');
			form.submit();
		}
		function getToken_esn(voValue){
			var form = $('#form1');
			form.prop('action', '${fn:url('/Index/chkCustId.action')}');
			form.append('<input type="hidden" name="function_num" value="4" />');
			form.append('<input type="hidden" name="token_esn" value="'+voValue+'" />');
			form.submit();
		}
		function chkCheckBox(obj){
			var id = obj.id+"";
			if(id.startsWith("permit") && $("#"+id).attr("checked")){
				var reverse = id.replace('permit','refuse');
				$("#"+reverse).attr("checked",false);
			}
			if(id.startsWith("refuse") && $("#"+id).attr("checked")){
				var reverse = id.replace('refuse','permit');
				$("#"+reverse).attr("checked",false);
			}
		}
	</script>
</head>
<body>
	<div class="errorDiv" style="display: none;">
		<table width="370px">
			<tr>
				<td>
					<textarea readonly id="error" style="width: 475px;height: 300px"></textarea>
				</td>
			</tr>
			<tr align="center">
				<td align="center">
					<input name="confirm" type="button" value="確定" class="closeDOMWindow"/>
				</td>
			</tr>
		</table>
	</div>
	<%@ include file="/form/include/title.jsp" %>
	<s:form id="form1">
		<s:hidden id="errorMsg" name="errorMsg"/>
		<s:if test="supvList.applyList.size()>0">
			<table align="center">
				<tr align="center">
					<td>待覆核<font color="red">申請</font>作業:共<s:property value="supvList.applyList.size()"/>件</td>
				</tr>
			</table>
			<!-- <p>待覆核<font color="red">申請</font>作業:共<s:property value="supvList.applyList.size()"/>件</p> -->
			<table class="table-style" align="center">
				<tr>
					<th style="width: 40px">項次</th>
					<th>日期</th>
					<th>客戶ID</th>
					<th>客戶名稱</th>
					<th>TOKEN ESN</th>
					<th>經辦</th>
					<th style="width: 40px">核准</th>
					<th style="width: 40px">拒絕</th>
					<th>註解</th>
				</tr>
				<s:iterator value="supvList.applyList" status="row" var="job">
					<tr>
						<td align="center"><s:property value="#row.index+1"/></td>
						<td><s:property value="date"/></td>
						<td><a onclick="getCustomer_id('${job.customer_id}')" href="#"><s:property value="customer_id"/></a></td>
						<td><s:property value="customer_name"/></td>
						<td><a onclick="getToken_esn('${job.token_esn}')" href="#"><s:property value="token_esn"/></a></td>
						<td><s:property value="operator"/></td>
						<td align="center"><s:checkbox id="permit_apply%{#row.index}" class="permit" name="supvList.applyList[%{#row.index}].permit" Value="permit" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td align="center"><s:checkbox id="refuse_apply%{#row.index}" class="refuse" name="supvList.applyList[%{#row.index}].refuse" Value="refuse" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td><s:textarea style="width: 200px;height: 30px; resize: none;" name="supvList.applyList[%{#row.index}].comment" theme="simple"></s:textarea></td>
						<td style="display: none;">
							<s:hidden name="supvList.applyList[%{#row.index}].job_id" value="%{#job.job_id}"/>
							<s:hidden name="supvList.applyList[%{#row.index}].job_code" value="%{#job.job_code}"/>
							<s:hidden name="supvList.applyList[%{#row.index}].customer_id" value="%{#job.customer_id}"/>
							<s:hidden name="supvList.applyList[%{#row.index}].group_id" value="%{#job.group_id}"/>
							<s:hidden name="supvList.applyList[%{#row.index}].customer_name" value="%{#job.customer_name}"/>
							<s:hidden name="supvList.applyList[%{#row.index}].token_esn" value="%{#job.token_esn}"/>
							<s:hidden name="supvList.applyList[%{#row.index}].token_status" value="%{#job.token_status}"/>
							<s:hidden name="supvList.applyList[%{#row.index}].operator" value="%{#job.operator}"/>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:if test="supvList.enableList.size()>0">
			<table align="center">
				<tr align="center">
					<td>待覆核<font color="red">啟用</font>作業:共<s:property value="supvList.enableList.size()"/>件</td>
				</tr>
			</table>
			<table class="table-style" align="center">
				<tr>
					<th style="width: 40px">項次</th>
					<th>日期</th>
					<th>客戶ID</th>
					<th>客戶名稱</th>
					<th>TOKEN ESN</th>
					<th>經辦</th>
					<th style="width: 40px">核准</th>
					<th style="width: 40px">拒絕</th>
					<th>註解</th>
				</tr>
				<s:iterator value="supvList.enableList" status="row" var="job">
					<tr>
						<td align="center"><s:property value="#row.index+1"/></td>
						<td><s:property value="date"/></td>
						<td><a onclick="getCustomer_id('${job.customer_id}')" href="#"><s:property value="customer_id"/></a></td>
						<td><s:property value="customer_name"/></td>
						<td><a onclick="getToken_esn('${job.token_esn}')" href="#"><s:property value="token_esn"/></a></td>
						<td><s:property value="operator"/></td>
						<td align="center"><s:checkbox id="permit_enable%{#row.index}" class="permit" name="supvList.enableList[%{#row.index}].permit" Value="permit" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td align="center"><s:checkbox id="refuse_enable%{#row.index}" class="refuse" name="supvList.enableList[%{#row.index}].refuse" Value="refuse" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td><s:textarea style="width: 200px;height: 30px; resize: none;" name="supvList.enableList[%{#row.index}].comment" theme="simple"></s:textarea></td>
						<td style="display: none;">
							<s:hidden name="supvList.enableList[%{#row.index}].job_id" value="%{#job.job_id}"/>
							<s:hidden name="supvList.enableList[%{#row.index}].job_code" value="%{#job.job_code}"/>
							<s:hidden name="supvList.enableList[%{#row.index}].customer_id" value="%{#job.customer_id}"/>
							<s:hidden name="supvList.enableList[%{#row.index}].group_id" value="%{#job.group_id}"/>
							<s:hidden name="supvList.enableList[%{#row.index}].customer_name" value="%{#job.customer_name}"/>
							<s:hidden name="supvList.enableList[%{#row.index}].token_esn" value="%{#job.token_esn}"/>
							<s:hidden name="supvList.enableList[%{#row.index}].token_status" value="%{#job.token_status}"/>
							<s:hidden name="supvList.enableList[%{#row.index}].operator" value="%{#job.operator}"/>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:if test="supvList.pauseList.size()>0">
			<table align="center">
				<tr align="center">
					<td>待覆核<font color="red">暫禁</font>作業:共<s:property value="supvList.pauseList.size()"/>件</td>
				</tr>
			</table>
			<table class="table-style" align="center">
				<tr>
					<th style="width: 40px">項次</th>
					<th>日期</th>
					<th>客戶ID</th>
					<th>客戶名稱</th>
					<th>TOKEN ESN</th>
					<th>經辦</th>
					<th style="width: 40px">核准</th>
					<th style="width: 40px">拒絕</th>
					<th>註解</th>
				</tr>
				<s:iterator value="supvList.pauseList" status="row" var="job">
					<tr>
						<td align="center"><s:property value="#row.index+1"/></td>
						<td><s:property value="date"/></td>
						<td><a onclick="getCustomer_id('${job.customer_id}')" href="#"><s:property value="customer_id"/></a></td>
						<td><s:property value="customer_name"/></td>
						<td><a onclick="getToken_esn('${job.token_esn}')" href="#"><s:property value="token_esn"/></a></td>
						<td><s:property value="operator"/></td>
						<td align="center"><s:checkbox id="permit_pause%{#row.index}" class="permit" name="supvList.pauseList[%{#row.index}].permit" Value="permit" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td align="center"><s:checkbox id="refuse_pause%{#row.index}" class="refuse" name="supvList.pauseList[%{#row.index}].refuse" Value="refuse" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td><s:textarea style="width: 200px;height: 30px; resize: none;" name="supvList.pauseList[%{#row.index}].comment" theme="simple"></s:textarea></td>
						<td style="display: none;">
							<s:hidden name="supvList.pauseList[%{#row.index}].job_id" value="%{#job.job_id}"/>
							<s:hidden name="supvList.pauseList[%{#row.index}].job_code" value="%{#job.job_code}"/>
							<s:hidden name="supvList.pauseList[%{#row.index}].customer_id" value="%{#job.customer_id}"/>
							<s:hidden name="supvList.pauseList[%{#row.index}].group_id" value="%{#job.group_id}"/>
							<s:hidden name="supvList.pauseList[%{#row.index}].customer_name" value="%{#job.customer_name}"/>
							<s:hidden name="supvList.pauseList[%{#row.index}].token_esn" value="%{#job.token_esn}"/>
							<s:hidden name="supvList.pauseList[%{#row.index}].token_status" value="%{#job.token_status}"/>
							<s:hidden name="supvList.pauseList[%{#row.index}].operator" value="%{#job.operator}"/>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:if test="supvList.unstallList.size()">
			<table align="center">
				<tr align="center">
					<td>待覆核<font color="red">解禁</font>作業:共<s:property value="supvList.unstallList.size()"/>件</td>
				</tr>
			</table>
			<table class="table-style" align="center">
				<tr>
					<th style="width: 40px">項次</th>
					<th>日期</th>
					<th>客戶ID</th>
					<th>客戶名稱</th>
					<th>TOKEN ESN</th>
					<th>經辦</th>
					<th style="width: 40px">核准</th>
					<th style="width: 40px">拒絕</th>
					<th>註解</th>
				</tr>
				<s:iterator value="supvList.unstallList" status="row" var="job">
					<tr>
						<td align="center"><s:property value="#row.index+1"/></td>
						<td><s:property value="date"/></td>
						<td><a onclick="getCustomer_id('${job.customer_id}')" href="#"><s:property value="customer_id"/></a></td>
						<td><s:property value="customer_name"/></td>
						<td><a onclick="getToken_esn('${job.token_esn}')" href="#"><s:property value="token_esn"/></a></td>
						<td><s:property value="operator"/></td>
						<td align="center"><s:checkbox id="permit_unstall%{#row.index}" class="permit" name="supvList.unstallList[%{#row.index}].permit" Value="permit" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td align="center"><s:checkbox id="refuse_unstall%{#row.index}" class="refuse" name="supvList.unstallList[%{#row.index}].refuse" Value="refuse" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td><s:textarea style="width: 200px;height: 30px; resize: none;" name="supvList.unstallList[%{#row.index}].comment" theme="simple"></s:textarea></td>
						<td style="display: none;">
							<s:hidden name="supvList.unstallList[%{#row.index}].job_id" value="%{#job.job_id}"/>
							<s:hidden name="supvList.unstallList[%{#row.index}].job_code" value="%{#job.job_code}"/>
							<s:hidden name="supvList.unstallList[%{#row.index}].customer_id" value="%{#job.customer_id}"/>
							<s:hidden name="supvList.unstallList[%{#row.index}].group_id" value="%{#job.group_id}"/>
							<s:hidden name="supvList.unstallList[%{#row.index}].customer_name" value="%{#job.customer_name}"/>
							<s:hidden name="supvList.unstallList[%{#row.index}].token_esn" value="%{#job.token_esn}"/>
							<s:hidden name="supvList.unstallList[%{#row.index}].token_status" value="%{#job.token_status}"/>
							<s:hidden name="supvList.unstallList[%{#row.index}].operator" value="%{#job.operator}"/>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:if test="supvList.invalidList.size()>0">
			<table align="center">
				<tr align="center">
					<td>待覆核<font color="red">註銷</font>作業:共<s:property value="supvList.invalidList.size()"/>件</td>
				</tr>
			</table>
			<table class="table-style" align="center">
				<tr>
					<th style="width: 40px">項次</th>
					<th>日期</th>
					<th>客戶ID</th>
					<th>客戶名稱</th>
					<th>TOKEN ESN</th>
					<th>經辦</th>
					<th style="width: 40px">核准</th>
					<th style="width: 40px">拒絕</th>
					<th>註解</th>
				</tr>
				<s:iterator value="supvList.invalidList" status="row" var="job">
					<tr>
						<td align="center"><s:property value="#row.index+1"/></td>
						<td><s:property value="date"/></td>
						<td><a onclick="getCustomer_id('${job.customer_id}')" href="#"><s:property value="customer_id"/></a></td>
						<td><s:property value="customer_name"/></td>
						<td><a onclick="getToken_esn('${job.token_esn}')" href="#"><s:property value="token_esn"/></a></td>
						<td><s:property value="operator"/></td>
						<td align="center"><s:checkbox id="permit_invalid%{#row.index}" class="permit" name="supvList.invalidList[%{#row.index}].permit" Value="permit" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td align="center"><s:checkbox id="refuse_invalid%{#row.index}" class="refuse" name="supvList.invalidList[%{#row.index}].refuse" Value="refuse" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td><s:textarea style="width: 200px;height: 30px; resize: none;" name="supvList.invalidList[%{#row.index}].comment" theme="simple"></s:textarea></td>
						<td style="display: none;">
							<s:hidden name="supvList.invalidList[%{#row.index}].job_id" value="%{#job.job_id}"/>
							<s:hidden name="supvList.invalidList[%{#row.index}].job_code" value="%{#job.job_code}"/>
							<s:hidden name="supvList.invalidList[%{#row.index}].customer_id" value="%{#job.customer_id}"/>
							<s:hidden name="supvList.invalidList[%{#row.index}].group_id" value="%{#job.group_id}"/>
							<s:hidden name="supvList.invalidList[%{#row.index}].customer_name" value="%{#job.customer_name}"/>
							<s:hidden name="supvList.invalidList[%{#row.index}].token_esn" value="%{#job.token_esn}"/>
							<s:hidden name="supvList.invalidList[%{#row.index}].token_status" value="%{#job.token_status}"/>
							<s:hidden name="supvList.invalidList[%{#row.index}].operator" value="%{#job.operator}"/>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:if test="supvList.batchList.size()">
			<table align="center">
				<tr align="center">
					<td>待覆核<font color="red">批次申請</font>作業:共<s:property value="supvList.batchList.size()"/>件</td>
				</tr>
			</table>
			<table class="table-style" align="center">
				<tr>
					<th style="width: 40px">項次</th>
					<th>日期</th>
					<th>檔名</th>
					<th>資料筆數</th>
					<th>經辦</th>
					<th>作業</th>
					<th style="width: 40px">核准</th>
					<th style="width: 40px">拒絕</th>
					<th>註解</th>
				</tr>
				<s:iterator value="supvList.batchList" status="row" var="job">
					<tr>
						<td align="center"><s:property value="#row.index+1"/></td>
						<td><s:property value="date"/></td>
						<td><s:property value="batch_file"/></td>
						<td><s:property value="batch_amount"/></td>
						<td><s:property value="operator"/></td>
						<td>批次配發TOKEN</td>
						<td align="center"><s:checkbox id="permit_batch%{#row.index}" class="permit" name="supvList.batchList[%{#row.index}].permit" Value="permit" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td align="center"><s:checkbox id="refuse_batch%{#row.index}" class="refuse" name="supvList.batchList[%{#row.index}].refuse" Value="refuse" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td><s:textarea style="width: 200px;height: 30px; resize: none;" name="supvList.batchList[%{#row.index}].comment" theme="simple"></s:textarea></td>
						<td style="display: none;">
							<s:hidden name="supvList.batchList[%{#row.index}].job_id" value="%{#job.job_id}"/>
							<s:hidden name="supvList.batchList[%{#row.index}].job_code" value="%{#job.job_code}"/>
							<s:hidden name="supvList.batchList[%{#row.index}].batch_file" value="%{#job.batch_file}"/>
							<s:hidden name="supvList.batchList[%{#row.index}].batch_amount" value="%{#job.batch_amount}"/>
							<s:hidden name="supvList.batchList[%{#row.index}].operator" value="%{#job.operator}"/>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:if test="supvList.custodyList.size()>0">
			<table align="center">
				<tr align="center">
					<td>待覆核<font color="red">TOKEN 入庫</font>作業:共<s:property value="supvList.custodyList.size()"/>件</td>
				</tr>
			</table>
			<!-- <p>待覆核<font color="red">TOKEN 入庫</font>作業:共<s:property value="supvList.custodyList.size()"/>件</p> -->
			<table class="table-style" align="center">
				<tr>
					<th style="width: 40px">項次</th>
					<th>日期</th>
					<th>檔名</th>
					<th>資料筆數</th>
					<th>經辦</th>
					<th>作業</th>
					<th style="width: 40px">核准</th>
					<th style="width: 40px">拒絕</th>
					<th>註解</th>
				</tr>
				<s:iterator value="supvList.custodyList" status="row" var="job">
					<tr>
						<td align="center"><s:property value="#row.index+1"/></td>
						<td><s:property value="date"/></td>
						<td><s:property value="batch_file"/></td>
						<td><s:property value="batch_amount"/></td>
						<td><s:property value="operator"/></td>
						<td>TOKEN入庫</td>
						<td align="center"><s:checkbox id="permit_custody%{#row.index}" class="permit" name="supvList.custodyList[%{#row.index}].permit" Value="permit" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td align="center"><s:checkbox id="refuse_custody%{#row.index}" class="refuse" name="supvList.custodyList[%{#row.index}].refuse" Value="refuse" theme="simple" onclick="chkCheckBox(this);"/></td>
						<td><s:textarea style="width: 200px;height: 30px; resize: none;" name="supvList.custodyList[%{#row.index}].comment" theme="simple"></s:textarea></td>
						<td style="display: none;">
							<s:hidden name="supvList.custodyList[%{#row.index}].job_id" value="%{#job.job_id}"/>
							<s:hidden name="supvList.custodyList[%{#row.index}].job_code" value="%{#job.job_code}"/>
							<s:hidden name="supvList.custodyList[%{#row.index}].batch_file" value="%{#job.batch_file}"/>
							<s:hidden name="supvList.custodyList[%{#row.index}].batch_amount" value="%{#job.batch_amount}"/>
							<s:hidden name="supvList.custodyList[%{#row.index}].operator" value="%{#job.operator}"/>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:if test="supvList.applyList.size()>0 
					|| supvList.pauseList.size()>0
					|| supvList.unstallList.size()>0
					|| supvList.invalidList.size()>0
					|| supvList.batchList.size()>0
					|| supvList.custodyList.size()>0
					|| supvList.enableList.size()>0">
			<table width="700" align="center">
				<tr height="50">
				<tr>
					<td align="center"><input type="button" name="btnOK" value="確定"/></td>
				<!--<td align="center"><input type="button" name="btnCancel" value="取消"/></td>-->
				</tr>
			</table>
		</s:if>
	</s:form>
</body>
</html>